<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="8" :lg="7" :md="8" :sm="24">
            <a-form-item label="身份证号">
              <a-input placeholder="请输入身份证号" v-model="queryParam.cardNo"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="8" :lg="7" :md="8" :sm="24">
            <a-form-item label="姓名">
              <a-input placeholder="请输入姓名" v-model="queryParam.cardName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="8" :lg="7" :md="8" :sm="24">
            <a-form-item label="手机号码">
              <a-input placeholder="请输入手机号码" v-model="queryParam.comboMobile"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="8" :lg="7" :md="8" :sm="24">
            <a-form-item label="订单时间">
              <a-range-picker format="YYYY-MM-DD" v-model="queryParam.orderTime" @change="onRangChange" />
            </a-form-item>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!-- <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button> -->
      <a-button type="primary" icon="download" @click="handleExportXls('SIM卡订单')">导出</a-button>
      <!-- <a-upload
        name="file"
        :showUploadList="false"
        :multiple="false"
        :headers="tokenHeader"
        :action="importExcelUrl"
        @change="handleImportExcel"
      >
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload> -->
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete" />删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a
        >项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        @change="handleTableChange"
      >
      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <simOrder-modal ref="modalForm" @ok="modalFormOk"></simOrder-modal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import moment from 'moment'
import SimOrderModal from './modules/SimOrderModal'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'

export default {
  name: 'untreatedOrders',
  mixins: [JeecgListMixin],
  components: {
    SimOrderModal,
  },
  data() {
    return {
      description: 'SIM卡订单管理页面',
      queryParam: {
        cardNo: '',
        cardName: '',
        contactsMobile: '',
        simOrderTime_begin: '',
        simOrderTime_end: '',
        comboMobile: ''
      },
      // 表头
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '订单编号',
          align: 'center',
          dataIndex: 'orderNo',
        },
        {
          title: '号码归属省份',
          align: 'center',
          dataIndex: 'cardAttributionProvince_dictText',
        },
        {
          title: '号码归属城市',
          align: 'center',
          dataIndex: 'cardAttribution_dictText',
        },
        {
          title: '身份证号',
          align: 'center',
          dataIndex: 'cardNo',
        },
        {
          title: '姓名',
          align: 'center',
          dataIndex: 'cardName',
        },
        {
          title: '商品名称',
          align: 'center',
          dataIndex: 'goodsName',
        },
        {
          title: '套餐名称',
          align: 'center',
          dataIndex: 'comboName',
        },
        {
          title: '套餐档次',
          align: 'center',
          dataIndex: 'comboLevel',
        },
        {
          title: '开卡⼿机号',
          align: 'center',
          dataIndex: 'comboMobile',
        },
        {
          title: '联系人手机号',
          align: 'center',
          dataIndex: 'contactsMobile',
        },
        {
          title: '收货地区',
          align: 'center',
          dataIndex: 'contactsCity',
        },
        {
          title: '收货详细地址',
          align: 'center',
          dataIndex: 'contactsAddress',
        },
        {
          title: '订单时间',
          align: 'center',
          dataIndex: 'simOrderTime',
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'status_dictText',
        },
      ],
      url: {
        list: '/sim/simOrder/list',
        delete: '/sim/simOrder/delete',
        deleteBatch: '/sim/simOrder/deleteBatch',
        exportXlsUrl: 'sim/simOrder/exportXls',
        importExcelUrl: 'sim/simOrder/importExcel',
      },
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    moment,
    onRangChange(data, dateString) {
      this.queryParam.orderTime = dateString
      this.queryParam.simOrderTime_begin = dateString[0]
      this.queryParam.simOrderTime_end = dateString[1]
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
